
/// <reference path="./module/ModuleMgr.ts" />
/// <reference path="./Define.ts" />
/// <reference path="./modules/define/ConfigDefine.ts" />
/// <reference path="./helper/ConfigHelper.ts" />

const startTime = Date.now()
console.log("apeng core versionCode:" + apeng.versionCode)

/**启动入口 主逻辑运行处*/
namespace apeng {

    /**版本sdk号，可到框架源码处查看更新日志 */
    export let versionCode: number

    /**多语言管理 */
    export let _language: LanguageModule = null!
    export let _server: ServerModule = null!

    /**框架模块管理 */
    export const moduleMgr = new ModuleMgr<EModuleType>()
    /**传入的静态初始化数据 */
    export let initData: IInitData = null!
    /**配置表数据 */
    export let _config_: ConfigHelper<TConfigFileName> = null!


    /**
     * 初始化主框架
     * @param data 静态数据
     * @param dataConfig 配置表数据
     */
    export function initCore(data: IInitData, complete?: (state: EInitCoreState) => void) {
        initData = data
        _config_ = new ConfigHelper(configs, ConfigFileName)

        // 加载模块
        moduleMgr.instance(false)
        _language = moduleMgr.get(EModuleType.language)
        _server = moduleMgr.get(EModuleType.server)

        moduleMgr.run(() => {

        }, EModuleType)

        console.log("apeng core complete duration:" + (Date.now() - startTime))
        if (complete)
            complete(EInitCoreState.init)
    }



}

